<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>班级管理</title>
    <link href="../../static/css/bootstrap.min.css" rel="stylesheet" th:href="@{/static/css/bootstrap.min.css}">
    <link href="../../static/css/dashboard.css" rel="stylesheet" th:href="@{/static/css/dashboard.css}">
</head>
<body>
<div th:insert="admin/common::topbar"></div>
<div class="container-fluid">
    <div class="row">
        <!--侧边栏-->
        <div th:insert="~{admin/common::sidebar(active='classInfo.html')}"></div>
        <main class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4" role="main">
            <div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pb-2 mb-3 border-bottom">
                <h1 class="h3">班级详情</h1>
                <div class="btn-toolbar mb-2 mb-md-0">
                    <div class="btn-group mr-2">
                        <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-admin">管理员</button>
                        <button class="btn btn-sm btn-outline-secondary" id="btn-student">学生端</button>
                    </div>
                </div>
            </div>
            <div class="table-responsive">
                <table class="table table-striped table-sm">
                    <thead>
                    <tr style="background-color: #0da8ee">
                        <th>班级号</th>
                        <th>教室</th>
                        <th>班主任</th>
                        <th>班级详情</th>
                        <th>操作</th>
                        <!--<th>年级</th>-->
                    </tr>
                    </thead>
                    <tbody>
                    <tr class="myClassInfo" th:each="list:${classInfo}">
                        <td th:text="${list.getClassid()}"></td>
                        <td th:text="${list.getClassroom()}"></td>
                        <td th:style="${list.getGuardian()!=null && list.getGuardian()!=''?'color:blue':'color:red'}"
                            th:text="${list.getGuardian()!=null && list.getGuardian()!=''?list.getGuardian():'未安排'}"></td>
                        <td>
                            <button class="btn btn-sm btn-success" th:value="${list.getClassid()}">班级学生</button>
                            <button class="btn btn-sm btn-info" th:value="${list.getClass_name()}">班级教师</button>
                        </td>
                        <td>
                            <button class="btn btn-primary btn-sm btn-outline-secondary" id="btn-add-guardian"
                                    th:value="${list.getClass_name()}">任免班主任
                            </button>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </main>
    </div>
</div>
<script src="../../static/js/jquery-3.6.0.min.js" th:src="@{/static/js/jquery-3.6.0.min.js}"
        type="text/javascript"></script>
<script src="../../static/js/bootstrap.min.js" th:src="@{/static/js/bootstrap.min.js}" type="text/javascript"></script>
<script>
    $(function () {
        $('.myClassInfo').each(function () {
            let studentList = $(this).children().eq(3).children().eq(0);
            let teacherList = $(this).children().eq(3).children().eq(1);
            let arrange = $(this).children().eq(4).children();
            let class_name = arrange.val();
            let classid = studentList.val();
            let className = teacherList.val();
            arrange.click(function () {
                $(location).attr('href', '/admin/toArrangeGuardian/' + class_name);
            })
            studentList.click(function () {
                $(location).attr('href', '/admin/getStudentListByClass/' + classid);
            })
            teacherList.click(function () {
                $(location).attr('href', '/admin/getTeacherByClass/' + className + '/1');
            })
        })
        $('#btn-admin').click(function () {
            let result = confirm("是否进入管理员登录?");
            if (result === true) {
                $(location).attr('href', '/adminLogin.html');
            } else {

            }
        })
        $('#btn-student').click(function () {
            let result = confirm("是否重新登录?");
            if (result === true) {
                $(location).attr('href', '/studentLogin.html');
            } else {

            }
        })
    })

</script>


</body>
</html>